# Define command line execMatlab (takes a string and executes it in MATLAB)
execMatlab () {
   /Applications/MATLAB_R2023b.app/bin/matlab -nodisplay -nosplash -r "$1" # for use with version R2023b of MATLAB (check installation path)
#    matlab -nodisplay -nosplash -r "$1"   # for use with other versions of MATLAB
}

# Add current folder in environment variable PYTHONPATH (to use package myutilities.py)
export PYTHONPATH="${PWD}:$PYTHONPATH"

### Pre-process data to produce folder data_csv
source a_0_processRawData.sh

### Load data (in csv format) into .mat files for use in MATLAB (get content from folder data_csv and produce folder data_mat)
source a_1_loadData2Matlab.sh

### Do EDA
source a_2_doEDA.sh

### Launch model estimation and model-based analyses
source a_3_doModelBasedAnalyses.sh

### Produce/copy exhibits
source a_4_produceExhibits.sh

### Compile tex files to obtain paper and web appendix in pdf format
cd tex
latexmk -pdf paper.tex
latexmk -pdf web_appendix.tex
rm paper.aux paper.bbl paper.blg paper.ent paper.fdb_latexmk paper.fls paper.log
rm web_appendix.aux web_appendix.bbl web_appendix.blg web_appendix.fdb_latexmk web_appendix.fls web_appendix.log web_appendix.toc

cd ..